<?php
if(isset($_POST['joketext'])){
    try{
        include __DIR__.'/../includes/DatabaseConnection.php';
        include_once __DIR__.'/../includes/DatabaseFunctions.php';

        insertJoke($pdo,$_POST['joketext'],1);

        header('location:jokes.php');
    }catch(PDOException $e){
        $title = 'error';
        $output = 'Database error:'.$e->getMessage().' in '.$e->getFile().':'.$e->getLine();
    }
}else{
    $title = '添加笑话';

    ob_start();

    include __DIR__.'/../templates/addjoke.html.php';
    $output = ob_get_clean();
}
include __DIR__.'/../templates/layout.html.php';